<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$title}</h2>

    </div>
    <div ng-controller="DingjiaCtrl" ng-cloak class="ng-cloak" ng-init="autospecpriceinit('{$batchid}','{$batch}')" style="font-size: 2px;">
        <span style="font-size: 20px;">该批次原包装共{{specInfo.ybzLength}}条，未匹配到正价商品的原包装<span style="color: red;">{{specInfo.noZj}}</span>条，共产生<span style="color: green">{{specInfo.total}}</span>条销售规格</span>
        <div class="data-table table-striped">
            <form method="POST" method="post" action="{:U('addsellspec')}" class="form-horizontal">
                <table>
                    <thead>
                        <tr>
                            <th>商品名称[规格]</th>
                            <th>成本</th>
                            <th>手工费</th>
                            <th>快递费</th>
                            <th>包装费</th>
                            <th>
                                商城<span class="glyphicon glyphicon-question-sign" title="含运120%"></span>
                            </th>
                            <th>
                                果饮店<span class="glyphicon glyphicon-question-sign" title="不含运105%"></span>
                            </th>
                            <th>
                                员工<span class="glyphicon glyphicon-question-sign" title="不含运115%"></span>
                            </th>
                            <th>
                                企事业<span class="glyphicon glyphicon-question-sign" title="不含运120%"></span>
                            </th>
                            <th >
                                批发<span class="glyphicon glyphicon-question-sign" title="不含运125%"></span>
                            </th>
                            <th >
                                广源<span class="glyphicon glyphicon-question-sign" title="不含运140%"></span>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="spec in specproduct">
                            <td>
                                {{spec.pname}}[{{spec.spec}}]
                                <input type="text" class="hide" name="pname[]" ng-model="spec.pname" >
                                <input type="text" class="hide" name="BIN[]" ng-model="spec.BIN" >
                            </td>
                            <td>
                                {{spec.priceNoFee}}
                                <input type="text" class="hide" name="base_price[]" ng-model="spec.priceNoFee" >
                            </td>
                            <td>
                                {{spec.process_fee|number:2}}
                                <input type="text" class="hide" name="process_fee[]" ng-model="spec.process_fee" >
                            </td>
                            <td>
                                {{spec.trans_fee|number:2}}
                                <input type="text" class="hide" name="gr_trans_fee[]" ng-model="spec.trans_fee" >
                            </td>
                            <td>
                                {{spec.subpro_fee|number:2}}
                                <input type="text" class="hide" name="package_fee[]" ng-model="spec.subpro_fee" >
                            </td>
                            <td>
                                {{spec.spec_price_sc|number:2}}
                                <input type="text" class="hide" name="spec_price_sc[]" ng-model="spec.spec_price_sc" >
                            </td>
                            <td>
                                {{spec.spec_price_gyd|number:2}}
                                <input type="text" class="hide" name="spec_price_gyd[]" ng-model="spec.spec_price_gyd" >
                            </td>
                            <td>
                                {{spec.spec_price_yg|number:2}}
                                <input type="text" class="hide" name="spec_price_yg[]" ng-model="spec.spec_price_yg" >

                            </td>
                            <td>
                                {{spec.spec_price_qsy|number:2}}
                                <input type="text" class="hide" name="spec_price_qsy[]" ng-model="spec.spec_price_qsy" >
                            </td>
                            <td>
                                {{spec.spec_price_pf|number:2}}
                                <input type="text" class="hide" name="spec_price_pf[]" ng-model="spec.spec_price_pf" >
                            </td>
                            <td>
                                {{spec.spec_price_gyds|number:2}}
                                <input type="text" class="hide" name="spec_price_gyds[]" ng-model="spec.spec_price_gyds" >
                                <input type="text" class="hide" name="batch[]"  value="{:I('batch')}" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="col-md-12" ng-show="specproduct.length>0">
                    <button type="submit" class=" btn btn-primary" target-form="form-horizontal">保存</button>
                    <a  class="btn btn-success" id="fh" onclick="javascript:history.back(-1); return false;">返 回</a>
                </div>
            </form>
        </div>
        <div class="modal fade" id="sellspecmodal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">销售规格定价</h4>
                    </div>
                    <div class="modal-body">
                        <form action="" method="post" id="sellspecform">
                        <table class="data-table" style="width: 100%">
                            <tr>
                                <th>商品[规格]</th>
                                <td colspan="3">
                                    <select select2 name="pname" class="form-control" style="width: 430px;" ng-change="sellprodcutselect(x)" ng-model="sellproduct.pname">
                                        <option  ng-repeat="p in sellproductlist" value="{{p.pname}}[{{p.spec}}]">{{p.BIN}}{{p.pname}}[{{p.spec}}]</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>定价批次</th>
                                <td>
                                    <select  name="batch" ng-change="basebatchselect(sellproduct.batch)" class="form-control input-4x" ng-model="sellproduct.batch">
                                        <option ng-repeat="b in batchlist">{{b.batch}}</option>
                                    </select>
                                </td>
                                <th>基础商品</th>
                                <td>
                                    <select name="base_product" ng-change="baseproductselect(sellproduct.base_index)" class="form-control input-3x" ng-model="sellproduct.base_index">
                                        <option value="{{($index)}}" ng-repeat="bp in baseproductlist">{{bp.erp_pname}}[{{bp.base_price}}]</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>成本价</th>
                                <td>
                                    <input type="text" name="base_price" ng-model="sellproduct.base_price" class="input-4x form-control"/>
                                </td>
                                <th>规格倍数</th>
                                <td>
                                    <input type="number" name="multi_num" ng-model="sellproduct.multi_num" class="input-3x form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <th>人工费</th>
                                <td>
                                    <input type="number" name="process_fee" ng-model="sellproduct.process_fee" class="input-4x form-control"/>
                                </td>
                                <th>快递费</th>
                                <td>
                                    <input type="number" name="tran_fee" ng-model="sellproduct.gr_trans_fee" class="input-3x form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5">
                                    <a ng-click="subproadd()" class="btn btn-sm btn-primary">添加耗材+</a>
                                </td>
                            </tr>
                            <tr ng-repeat="sub in sellproduct.subpro">
                                <th>
                                    <a class="btn btn-primary" ng-click="subproremove($index)">-</a>
                                    耗材[单价]
                                </th>
                                <td>
                                    <select select2 name="subpro_pname[]" class="form-control input-4x" ng-model="sub.subpro_unit_price">
                                        <option ng-repeat="subpro in subprolist" value="{{subpro.unitprice}}">{{subpro.pname}}[￥{{subpro.unitprice}}元]</option>
                                    </select>
                                </td>
                                <th>耗材数</th>
                                <td>
                                    <input type="number" name="subpro_num[]" ng-model="sub.subpro_num" class="input-3x form-control"/>
                                </td>
                            </tr>
                        </table>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" ng-click="spec_count_price()">定价</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="exampleModal" tabindex="-1" style="margin:200px;width: 100%;height: 100%" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document" style="">
            </div>
        </div>
        <div class="page">
            {$_page}
        </div>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript" src="__JS__/dingjia.js"></script>
    <script type="text/javascript">

    </script>
</block>
